#include "mainwindow.h"

#include <QDebug>

#include "./ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); }

MainWindow::~MainWindow() { delete ui; }

void MainWindow::on_backBtn_clicked() {
    auto index = ui->stackedWidget->currentIndex();
    if (index > 0) {
        ui->stackedWidget->setCurrentIndex(--index);
        if (!ui->nextBtn->isEnabled()) ui->nextBtn->setEnabled(true);
    }
    if (index <= 0) ui->backBtn->setDisabled(true);
}

void MainWindow::on_nextBtn_clicked() {
    auto index = ui->stackedWidget->currentIndex();
#if 0
    qDebug() << ui->stackedWidget->count() << Qt::endl;
#endif
    if (index < ui->stackedWidget->count() - 1) {
        ui->stackedWidget->setCurrentIndex(++index);
        if (!ui->backBtn->isEnabled()) ui->backBtn->setEnabled(true);
    }
    if (index >= ui->stackedWidget->count() - 1) ui->nextBtn->setDisabled(true);
}
